package com.extrace.server.pojo;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

import javax.persistence.*;
import java.sql.Timestamp;

@Entity
@Data
@Table(name = "express")
public class Express {
    @Id
    private String id; // id
    private Integer type; // 类型
    private Float weight; // 重量
    private Float fee; // 费用
    private Integer status; // 状态
    private Integer sender; // 寄件人 Id
    private Integer receiver; // 收件人 id
    @Column(name = "customer_id")
    private Integer customerId; // 下单的人的 id

    @Column(name = "create_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Timestamp createTime;
    private Integer picker; // 揽收人员
    @Column(name = "pick_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Timestamp pickTime;
    private Integer deliver; // 派送人员
    @Column(name = "deliver_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Timestamp deliverTime;
    private Integer signer; // 签收人 id
    @Column(name = "sign_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Timestamp signTime;


    @TableLogic(value = "0", delval = "1")
    @TableField(fill = FieldFill.INSERT)
    @Column(name = "delete_flag")
    private Integer deleteFlag;


    private Integer score; // 对派送人员的评分

    private Integer notified; // 表示是否已经通知过

//    private Integer routeType; // 表示路线的类型 1 同市 2 同省 3 跨省

    @Transient
    @TableField(exist = false)
    private Customer rcv; // 收件人
    @Transient
    @TableField(exist = false)
    private Customer snd; // 寄件人
    @Transient
    @TableField(exist = false)
    private User pic; // 揽收人员
    @Transient
    @TableField(exist = false)
    private User dlv; // 派送人员
    @Transient
    @TableField(exist = false)
    private Customer sig; // 签收人


    @Override
    public String toString() {
        return "Express{" +
                "id='" + id + '\'' +
                ", type=" + type +
                ", weight=" + weight +
                ", fee=" + fee +
                ", status=" + status +
                ", sender=" + sender +
                ", receiver=" + receiver +
                ", createTime=" + createTime +
                ", picker=" + picker +
                ", pickTime=" + pickTime +
                ", deliver=" + deliver +
                ", deliverTime=" + deliverTime +
                ", signer=" + signer +
                ", signTime=" + signTime +
                ", rcv=" + rcv +
                ", snd=" + snd +
                ", pic=" + pic +
                ", dlv=" + dlv +
                ", sig=" + sig +
                '}';
    }

    public static final class STATUS {
        public static final int STATUS_CANCEL = -1; // 取消
        public static final int STATUS_CREATED = 0;  // 快件已创建
        public static final int STATUS_PICKED = 1;  // 快件已揽收
        public static final int STATUS_TRANSPORTING = 2;  // 快件运输中
        public static final int STATUS_DELIVERING = 3;  // 快件派送中
        public static final int STATUS_SIGNED = 4;  // 快件已签收
        public static final int STATUS_SORTED = 5;//快件已分拣
        public static final int STATUS_UNSORTED = 6;//快件未分拣
        public static final int STATUS_WAIT_DELIVER = 7; // 快件待派送
        public static final int STATUS_WAIT_EVALUATE = 8; // 待评价
        public static final int STATUS_EVALUATED = 9; // 已评价
    }
}
